<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.lib.*" %>
<%@ page import="com.ionglobal.misc.*" %>

<%@ include file="../init_include.jsp" %>

<%
	int catid=0;
	int totalpages=0,pageid=0;
	int pagerows=Page.getPageRows();
	int totalrows=0;
	int titleMaxLen=20;
  String ordermode="desc";
  String orderfield="tablename.first_field";
  			
	int check_rst=Permission.accept(dbi,session,request,"sysop","tree","catid","000000010"); 
	if (check_rst!=Permission.CHECK_RST_SUCCESS) {
		if (check_rst==Permission.CHECK_RST_DENY) {
			int checkcat_rst=Permission.accept(dbi,session,request,"sysop","tree","catid","000100000"); 
			if (checkcat_rst!=Permission.CHECK_RST_SUCCESS) {
				dbi.closeAll();				
				response.sendRedirect("../deny.html");			
			} else {
				response.sendRedirect("../sys/showCateInfo.jsp?catid="+request.getParameter("catid"));			
			}
		}
		else {
			dbi.closeAll();		
			response.sendRedirect("../index.jsp");
		}
		return;		
	}
	
	Sysop sysop=(Sysop)session.getAttribute("sysop");
	Vector tree=(Vector)session.getAttribute("tree");
	String permissionStr=Permission.getPermissionStr(dbi,session,catid);
	boolean CanItemAdd=PermissionItem.Can(permissionStr,PermissionItem.ItemAdd);
	boolean CanItemDel=PermissionItem.Can(permissionStr,PermissionItem.ItemDel);
	boolean CanItemEdit=PermissionItem.Can(permissionStr,PermissionItem.ItemEdit);
	
	String a=request.getParameter("catid");
	String str="";
	try {
		catid=Integer.parseInt(a);		
	}	catch(NumberFormatException e) {
		out.println(e+"catId");
		return;
	}

	if(request.getParameter("ordermode")!=null)
		ordermode=request.getParameter("ordermode");	
	if(request.getParameter("orderfield")!=null)
		orderfield=request.getParameter("orderfield");		
		
	try {
		if (request.getParameter("pageid")!=null)
			pageid=Integer.parseInt(request.getParameter("pageid"));
		else
			pageid=1;
	}	catch(NumberFormatException e) {
		out.println(e+"pageid");
		pageid=1;
	}	
	
	try {
		if (request.getParameter("pagerows")!=null)
			pagerows=Integer.parseInt(request.getParameter("pagerows"));
	} catch(NumberFormatException e) {
		out.println(e+"pagerows");
	}	

	Category cat=new Category(dbi,catid);
	a=cat.getName();
	String sql="";
	try {
		sql="select count(*) as cnt from tablename";
		dbi.execQuery(sql);
		if (dbi.rsNext())
 			totalrows=dbi.rsGetInt("cnt");
		dbi.rsClose();
		totalpages = (int)Math.ceil((double)totalrows/pagerows);
	} catch(Exception E) {
	}
	if(pageid>totalpages)
		pageid=totalpages;
	if(pageid<=1)
		pageid=1;
%>	
<html>
<head>
<title>tabledescript</title>
<meta http-equiv="Content-Type" content="text/html; charset=<%=Language.getHTMLLanguageStr()%>">
<link rel="stylesheet" href="<%=Language.getCSSFile(session)%>" type="text/css">
<SCRIPT language=JavaScript1.2 src="../script/Ion_Show.js"></SCRIPT>
<script language="javascript">
<!--

	<%if(CanItemAdd) {%>	
	function Ion_Add() {
		addIon('vmsSelectFrame.jsp','tablename_dj.jsp');
	}	
	<%}%>	
	
	<%if(CanItemDel) {%>	
	function Ion_Del() {
		deleteIon('vmsSelectFrame.jsp','tablename_delete.jsp','tabledescript');		
	}	
	<%}%>	
	
	<%if(CanItemEdit) {%>	
	function Ion_Edit() {
		editIon('vmsSelectFrame.jsp','tablename_dj.jsp','tabledescript');
	}		
	<%}%>	
-->
</script>
</head>

<body bgColor=#d6d3ce leftMargin=0 
style="BORDER-BOTTOM: 0px outset; BORDER-LEFT: 0px outset; BORDER-RIGHT: 0px outset; BORDER-TOP: 0px outset" 
topMargin=0>

<FORM name="formIon" method="post" action="tablename_bro.jsp" onsubmit="">
<table width="100%" border="0" cellspacing="1" cellpadding="2">
  <tr>
    <td class="nagivation" colspan="2"><%=Language.getNameByCode("sys.CurrentPos","Current Position")%>:
    <% 
    Vector vcpath=Category.getLadder(session,"tree",catid);
		out.print(Category.getFullPath(vcpath));
		%>
		</td>
  </tr>
	<tr>
 	 <td align="left"><%=Language.getNameByCode("sys.list"," List")%><%=PageStr.getPageHead(totalrows,pageid,pagerows,totalpages)%>
 	 </td>
 	 <td align=right>
   	<%=PageStr.PageForm(pageid,totalpages)%><input type="submit" name="Submit" value="go" style="width:0">
   </td>
  </tr>
</table>

	<TABLE border=0 cellPadding=0 cellSpacing=1 height="100%" width="100%">
		<input type="hidden" name="catid" value="<%=catid%>">
		<input type="hidden" name="id" value="<%=catid%>">
		<INPUT name="objid" type="hidden">
		<INPUT name="objtext" type="hidden">
		<INPUT name="objflag" type="hidden">
		<INPUT name="actionurl" type="hidden">
		<input type="hidden" name="orderfield" value="<%=orderfield%>">
		<input type="hidden" name="ordermode" value="<%=ordermode%>">
  	<TR>
    <TD>
    <APPLET code=com.ionglobal.gui.Table codeBase=../ height="100%" name=table1 width="100%" VIEWASTEXT mayscript archive="gui.jar">
    <PARAM NAME="columnCount" VALUE="8">    
    <PARAM NAME="header" VALUE="no|<insert fielddescript in here>">
    <%	
   	<insert paradim in here>
 	 	sql="<insert selectsql in here> order by "+orderfield+" "+ordermode;
   	dbi.skipToPage(pagerows,pageid,sql);
   	int record_count=0;
 	  while(dbi.rsNext())     
	  {
	  	if(record_count>=pagerows && pagerows!=0)	  	
	  		break;
	  <insert getrecord in here>
%>
		<PARAM NAME="row_<%=record_count%>" VALUE="<%=first_field%>|<insert fieldvalue in here>">
		<PARAM NAME="cellImage_<%=record_count%>_1" VALUE="../images/item.gif">
<% 	
	  	record_count++;
		}
		dbi.rsClose();
		int count=0;
%>   
		<PARAM NAME="sortMode" VALUE="<%=ordermode%>">
    <PARAM NAME="sortField" VALUE="<%=orderfield%>">
    <PARAM NAME="sortFieldList" VALUE="first_field,<insert fieldlist in here>">    
    <PARAM NAME="fieldseparator" VALUE="|">
    <PARAM NAME="urlColor" VALUE="black">
    <PARAM NAME="urlStyle" VALUE="noline">
	<%if(CanItemEdit) {%>
    <PARAM NAME="menu<%=count%>" VALUE="<%=Language.getNameByCode("sys.Edit","Edit Selected ")%>tabledescript">
    <PARAM NAME="menuurl<%=count%>" VALUE="javascript:Ion_Edit();">
    <%count++;%>
	<%}%>	
	<%if(CanItemAdd) {%>
    <PARAM NAME="menu<%=count%>" VALUE="<%=Language.getNameByCode("sys.Add","Add New ")%>tabledescript">
    <PARAM NAME="menuurl<%=count%>" VALUE="javascript:Ion_Add();">
    <%count++;%>
	<%}%>	
    <PARAM NAME="separator<%=count%>" VALUE="Y">    
    <PARAM NAME="menu<%=count%>" VALUE="<%=Language.getNameByCode("sys.Head.Refresh","Refresh")%>">
    <PARAM NAME="menuurl<%=count%>" VALUE="javascript:self.location.reload();">
	<%if(CanItemDel) {%>
    <PARAM NAME="separator<%=count%>" VALUE="Y">
    <%count++;%>
    <PARAM NAME="menu<%=count%>" VALUE="<%=Language.getNameByCode("sys.Delete","Delete Selected ")%>tabledescript">
    <PARAM NAME="menuurl<%=count%>" VALUE="javascript:Ion_Del()">
	<%}%>	
    <PARAM NAME="urltarget" VALUE="header1">
    <PARAM NAME="alternateRowBackground" VALUE="#D0E8FF">
    <PARAM NAME="font" VALUE="Arial,plain,12">
    <PARAM NAME="selectionMode" VALUE="multiple">
    <PARAM NAME="gridOn" VALUE="false">
    <PARAM NAME="gridColor" VALUE="#808080">
    <PARAM NAME="filterBarOn" VALUE="true">
    <PARAM NAME="columnWidth" VALUE="0,30,250,60,80,40,40,40">
    <PARAM NAME="totalRowOn" VALUE="true">
    <PARAM NAME="decimalCount_10" VALUE="0">
    <PARAM NAME="headerAlignment" VALUE="center,center,center,center,center,center,center,center">
    <PARAM NAME="columnAlignment" VALUE="left,left,left,left,left,left,left,left">
    <PARAM NAME="columnType" VALUE="number,text,text,text,text,text,number,text">
    <PARAM NAME="code" VALUE="com.ionglobal.gui.Table">
    <PARAM NAME="codeBase" VALUE="../">
    <PARAM NAME="height" VALUE="100%">
    <PARAM NAME="name" VALUE="table1">
    <PARAM NAME="width" VALUE="100%">
    <PARAM NAME="VIEWASTEXT" VALUE="">
    <PARAM NAME="mayscript" VALUE="">
    <PARAM NAME="archive" VALUE="gui.jar">
    </APPLET>
	  </TD>
 	</TR>
	</TABLE>
</FORM>
</body>
</html>
<%@ include file="../init_free.jsp" %>